# The configuration file of bashy2.

modes=12
irc_port=6667
irc_host='irc.sdf.org'
irc_pass="$HOME/.oline"

cmd_dir='./bits/commands'

if [[ "$HOSTNAME" = 'iceland' ]] || [[ "$HOSTNAME" = 'sverige' ]]; then
    bot_user='BASHy2'
    bot_nick='BASHy2'
    bot_nick2='BASHy2-EU'
    bot_real='A BASH Bot'
elif [[ "$HOSTNAME" = 'odin' ]]; then
    bot_user="BASHy2-EU"
    bot_nick='BASHy2-EU'
    bot_nick2='BASHy2'
    bot_real='BASHy2 in Europe'
else
    printf '\n%s\n\n' 'Where am I?'
    exit 1
fi

function auth {
    # Authenticates users based on their username and host.
    if [[ "$nick" = "$bot_nick" ]]; then
        flag='aohv'
    else
        flag=''
        case "$host" in
            'mab.sdf.org'|'ma.sdf.org'|'iceland.sdf.org'|'vps2.sdf.org'|'oper.sdf.org')
                flag='ohv'
                return ;;
            *'.sdf.org'|'sdf.lonestar.org'|'sdf.org')
                flag='v'
                test "$HOSTNAME" = 'odin' && return ;;
            *'.sdf-eu.org'|'sdf-eu.org'|*'.sdfeu.org'|'sdfeu.org')
                flag='v'
                test "$HOSTNAME" = 'iceland' && return ;;
            *)
                return ;;
        esac
        case "$(id "$user")" in
            *'600(MetaARPA)'*)
                flag='ohv' ;;
            *'500(arpa)'*)
                flag='hv' ;;
        esac
    fi
}

function 2botpriv {
    # Ensures the bots won't play /msg ping pong.
    if [[ "$nick" = "$bot_nick2" ]]; then
        return 0
    fi
}

function 2botjoin {
    # Silences the bot when the other one takes over.
    if [[ "$nick" = "$bot_nick2" ]]; then
        quiet=0
    fi
}

function 2botquit {
    # Makes the bot take over when the other one quits.
    local nick="${1:1}"
    if [[ "$nick" = "$bot_nick2" ]]; then
        quiet=1
    fi
}

